<template>
	<view>
		<u-swiper :list="banners" showTitle :current="current" @change="changeImage" keyName="image" indicator autoplay
			:height="180" indicatorMode="line" circular>
		</u-swiper>
		
		<view  class="page_content">
			<image style="width: 264rpx;height: 54rpx;margin-top: 24rpx;margin-bottom: 24rpx;"
				src="@/static/images/img_title1.png"></image>
			<view class="flex_between_start">
				<view class="home_flex_1" @click="handlePath('/pages/3DStatueMaking', 3)">
					<view style="padding-top: 40rpx;">3D造像馆</view>
					<image style="width: 200rpx;height: 200rpx;margin-top: 24rpx;" src="@/static/images/home_1.png"></image>
				</view>
				<view class="flex_1">
					<view class="home_flex_3" @click="handlePath('/pages/create3D', 3)">
						<image style="width: 100rpx;height: 100rpx;" src="@/static/images/home2.png"></image>
						<view style="padding-left: 12rpx;">3D造物坊</view>
					</view>
					<view class="home_flex_3" @click="handlePath('/pages/stereoscopic', 3)">
						<image style="width: 100rpx;height: 100rpx;" src="@/static/images/home3.png"></image>
						<view style="padding-left: 12rpx;">立体还原机</view>
					</view>
				</view>
			</view>
			
			<image style="width: 264rpx;height: 54rpx;margin-bottom:24rpx;"
				src="@/static/images/img_title2.png"></image>
			<scroll-view class="scroll-view1" scroll-x="true">
				<view style="display:flex;">
					<view class="scroll-flex" @click="handlePath('/pages/wander', 1)">
						<image class="scroll-img" src="@/static/images/home4.png"></image>
						<view class="scroll-item">
							<view style="padding-bottom:36rpx;">飞跃科大</view>
							<image style="width: 180rpx;height: 54rpx;" src="@/static/images/go.png"></image>
						</view>
					</view>
					<view class="scroll-flex" @click="handlePath('/pages/wander', 1)">
						<image class="scroll-img" src="@/static/images/home5.png"></image>
						<view class="scroll-item">
							<view style="padding-bottom:36rpx;">3D找茬</view>
							<image style="width: 180rpx;height: 54rpx;" src="@/static/images/go.png"></image>
						</view>
					</view>
					<view class="scroll-flex" @click="handlePath('/pages/wander', 2)">
						<image class="scroll-img" src="@/static/images/home5.png"></image>
						<view class="scroll-item">
							<view style="padding-bottom:36rpx;">魔力精灵</view>
							<image style="width: 180rpx;height: 54rpx;" src="@/static/images/go.png"></image>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
		
	</view>
</template>

<script>
	import {
		modelList,getTicketNum
	} from '@/api/common.js'
	import {
		getToken
	} from '@/utils/auth'
	import config from '@/config.js'
	import home from '@/static/images/banner.png'
	export default {
		data() {
			return {
				loadingText: '新质3D生产力',
				current: 0,
				showAgree: false,
				userBtn: true,
				userInfo: {},
				threeDList: [],
				wanderList: [],
				banners: [
					// 	{
					// 	image: 'https://platform.real-infinity.cn/images/ec373805461975a20fc2c5b50e2b2c6e.jpg',
					// 	title: '更广阔的视界,更逼真的细节',
					// }, {
					// 	image: 'https://platform.real-infinity.cn/images/6cca17353128abc3f64525a37629e3ff.jpg',
					// 	title: '更动感的情境,更生动的叙事'
					// }, 更智能的融合,更友好的交互
					{
						image: home,
						title: ''
					}
				],
			}
		},
		onLoad() {
			// this.getAllApi()
		},
		methods: {
			changeImage(e) {
				this.current = e.current
			},
			handleTab(url) {
				uni.switchTab({
					url: url
				});
			},
			handleDetail(item) {
				if (item.buildModelId == 107) {
					uni.navigateTo({
						url: '/pages/wander?type=2'
					});
				} else {
					uni.navigateTo({
						url: '/pages/animation?data=' + JSON.stringify(item)
					});
				}
			},
			getAllApi() {
				// 3D工坊
				modelList({
					displayType: 0,
					pageNum: 1,
					pageSize: 4
				}).then(res => {
					let rows = res.rows
					rows.forEach(item => {
						item.src = config.baseImg + item.logo
					})
					this.threeDList = rows
				})
				// 实景云游
				modelList({
					displayType: 1,
					pageNum: 1,
					pageSize: 3
				}).then(res => {
					let rows = res.rows
					rows.forEach(item => {
						item.src = config.baseImg + item.logo
					})
					this.wanderList = rows
				})
			},
			async handlePath(url, type) {
				if (type == 3) {
					const res = await getTicketNum() 
					if (getToken()) {
						uni.navigateTo({
							url: url + '?type=' + type
						});

					} else {
						uni.showToast({
							title: "请先登录授权",
							icon: "none"
						});
						uni.switchTab({
							url: '/pages/tabbar/my'
						})
					}
				} else if (type == 2) {
					uni.showToast({
						title: "努力上线中，敬请期待",
						icon: "none"
					});
				} else {
					uni.navigateTo({
						url: url + '?type=' + type
					});
				}
			}
		}
	}
</script>
<style scoped lang="scss">
	.page_content {
		padding-top: 0;
	}

	/deep/ .u-swiper__wrapper {
		background-color: #FAFAFA;
	}

	.scroll-view1 {
		white-space: nowrap;
		width: 100%;
		position: relative;
	}

	.scroll-flex {
		width: 33%;
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
	}

	.scroll-item {
		display: inline-block;
		width: 264rpx;
		background-color: #ffffff;
		margin-right: 10px;
		text-align: center;
		border-radius: 24rpx;
		padding-top: 100rpx;
		padding-bottom: 10rpx;
		margin-top: -40px;
	}

	.scroll-img {
		width: 144rpx;
		height: 144rpx;
		z-index: 99;
	}

	.home_flex_1 {
		width: 48%;
		margin-right: 2%;
		border-radius: 24rpx;
		background-color: #FFFFFF;
		text-align: center;
		height: 160px;
	}

	.home_flex_3 {
		width: 100%;
		border-radius: 24rpx;
		margin-bottom: 24rpx;
		background-color: #FFFFFF;
		display: flex;
		justify-content: flex-start;
		align-content: center;
		align-items: center;
		height: 75px;
	}

	.flex_2 {
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
	}

	.home_flex {
		width: 49%;
		position: relative;

		.home_flex_abs {
			position: absolute;
			left: 50%;
			top: 40%;
			font-weight: 500;
			font-size: 34rpx;
			color: #ffffff;
			transform: translate(-50%, -50%)
		}
	}

	.home_rel {
		position: relative;
		margin-top: 32rpx;
	}

	.home_abs {
		position: absolute;
		left: 10%;
		top: 30%;
		font-weight: 600;
		font-size: 56rpx;
		color: #ffffff;
	}

	/deep/ .u-popup__content {
		background-color: #fff;
		padding: 40rpx 0 0;
		width: calc(100% - 72rpx);
		margin: 0 auto;
		border-radius: 16rpx;

		.pop_content {
			padding: 0 48rpx 48rpx;
		}

		.pop_title {
			font-size: 36rpx;
			font-weight: 600;
			text-align: center;
			padding-bottom: 40rpx;
		}

		.btn {
			width: 100%;
			height: 72rpx;
			border-radius: 40rpx;
			font-size: 30rpx;
			background: $uv-main-color;
			color: #FFFFFF;
		}
	}

	.three:nth-child(2n-1) {
		margin-right: 2%;
	}

	/deep/ .u-swiper_title1 {
		bottom: 50% !important;
		left: 15% !important;
	}

	/deep/ .u-swiper_title2 {
		bottom: 30% !important;
		left: 40% !important;
	}
</style>